package com.oc.claimobs.bb.gps;

import javax.microedition.location.LocationException;
import javax.microedition.location.LocationListener;
import javax.microedition.location.LocationProvider;

public class LocationService {
	
	private static int _interval = 1; 
    private LocationProvider _locationProvider;    
    
    public LocationService(LocationListener listener){
    	initService(listener);
    }
    
    public boolean initService(LocationListener listener)
    {
        boolean retval = false;
        
        try
        {
            _locationProvider = LocationProvider.getInstance(null);
            
            if ( _locationProvider == null )
            {
                //Location Not Available;  
            }
            else
            {
                _locationProvider.setLocationListener(listener,_interval, 1, 1);
                
                retval = true;
                
            }
        }
        catch (LocationException le)
        {
            System.err.println("Failed to instantiate the LocationProvider object, exiting...");
            System.err.println(le); 
            System.exit(0);
        }        
        return retval;
    }
}
